﻿@using JinRiAdmin.WebHost.ViewModels
@using PagedList
@using PagedList.Mvc
@{
    ViewBag.Title = "职位列表";
    var paged = ViewBag.Paged as IPagedList<JobModel>;
}

<div class="box">
    <div class="box-body table-responsive">
        <div class="form-inline" role="grid">
            <div class="row">
                <div class="col-xs-11">
                    <a class="btn btn-app" href="@Url.Action("Add")">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                </div>
            </div>
            <table class="table table-bordered table-hover dataTable">
                <thead>
                    <tr role="row">
                        <th rowspan="1" colspan="1">标题</th>
                        <th rowspan="1" colspan="1">创建时间</th>
                        <th rowspan="1" colspan="1">修改时间</th>
                        <th rowspan="1" colspan="1">编辑</th>
                        <th rowspan="1" colspan="1">删除</th>
                    </tr>
                </thead>
                <tbody role="alert">
                    @foreach (var item in paged)
                    {
                        <tr>
                            <td>@item.Title</td>
                            <td>@item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            <td>@item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            <td><a href="@Url.Action("Edit",new{id=item.Id})" class="btn btn-default"><i class="fa fa-edit"></i>编辑</a></td>
                            <td><a href="javascript:;" data-id="@item.Id" class="btn btn-default delete"><i class="fa fa-times-circle"></i>删除</a></td>
                        </tr>
                    }
                </tbody>
            </table>
            <div class="row">
                <div class="col-xs-11">
                    @Html.PagedListPager(paged, page => Url.Action("List", new { page = page }), PagedListRenderOptions.OnlyShowFivePagesAtATime)
                </div>
            </div>
        </div>
    </div>
</div><!-- /.box-body -->
@section Scripts{
    <script>
        $(function () {
            $('.dataTable').on('click', '.delete', function () {
                if (!confirm('确定删除吗？')) {
                    return false;
                }

                var $el = $(this);
                var id = $el.data('id');
                $.post('@Url.Action("Delete")', { id: id }, function () {
                    $el.closest('tr').remove();
                });
            });
        });
    </script>
}

